class HashTable{
	private LinkList[] hashArray;
	
public HashTable(int size){
   hashArray = new LinkList[size];
   for(int i=0; i < hashArray.length; i++)
	hashArray[i] = new LinkList();
	
}
	public void displayTable(){
	System.out.println("\n The Hash Table :");
	for(int i=0; i < hashArray.length; i++){
		System.out.print(" "+i + ": ");
		hashArray[i].displayList();
		}
	}
	public int hashFunction(String key){
		int val=0;
		String conVal="";
		for (int k=0; k<key.length(); k++)
		{
			val = key.charAt(k);
			//System.out.println(" "+val);
			conVal =conVal +val;
			//System.out.println(" "+conVal);
		}
		return Integer.parseInt(conVal.substring(0,5))%hashArray.length;
}	
	public void addHash(String ind,String eng) {
	int hashVal = hashFunction(ind);
	System.out.println("hashval"+hashVal);
	if(hashArray[hashVal].isEmpty())
	{
	hashArray[hashVal].addLink(ind,eng);
	}else {
	for(int h=0; h<hashArray.length; h++){
	if(hashArray[h].isEmpty())
	{
	hashArray[h].addLink(ind,eng);
	break;
	}

}
}
}	
	public Link find(String ind) {
	int hashVal = hashFunction(ind);
	//System.out.print(" At index "+hashVal + " ");
	for(int h=0; h<hashArray.length; h++)
	{
	if (hashArray[h].findLink(ind)!=null)
	{
		break;
	}
	}
	return hashArray[hashVal].findLink(ind);
}
}


